<?php

class CommonClass {

    var $email = array();
    var $statusarr = array();
    var $http = 'http://';
    var $zoneproductarr = array();
    var $html;

    function emailto($email) {
        $emailarr = explode('@', $email);
        $urllength = stripos($emailarr['1'], '.');
        $url = substr($emailarr['1'], 0, $urllength);
        $this->email = array(
            '163' => 'mail.163.com',
            '126' => 'mail.126.com',
            'foxmail' => 'mail.foxmail.com',
            'qq' => 'mail.qq.com',
            'hotmail' => 'login.live.com',
            'sohu' => 'mail.sohu.com',
            'sina' => 'mail.sina.com.cn',
            'yahoo' => 'login.yahoo.com',
            'gmail' => 'mail.gmai.com'
        );
        return $this->http . $this->email[$url];
    }

    function orderstatus($status, $orderid) {
        $this->statusarr = array(
            '0' => '订单已取消',
            '1' => '等待付款，<a href="' . Yii::app()->baseUrl . '/order/payways/' . urlencode(base64_encode(Yii::app()->user->id . '|' . $orderid)) . '">立即付款</a><br/>或者&nbsp;&nbsp;<a href="javascript:void(0);" onclick="ajaxWindow(\'取消订单\', \'closeOrder&id=' . urlencode(base64_encode(Yii::app()->user->id . '|' . $orderid)) . '\',\'account\');">取消订单</a>',
            '2' => '付款失败，<a href="' . Yii::app()->baseUrl . '/order/payways/' . urlencode(base64_encode(Yii::app()->user->id . '|' . $orderid)) . '">重新付款</a><br/>或者&nbsp;&nbsp;<a href="javascript:void(0);" onclick="ajaxWindow(\'取消订单\', \'closeOrder&id=' . urlencode(base64_encode(Yii::app()->user->id . '|' . $orderid)) . '\',\'account\');">取消订单</a>',
            '3' => '等待收货，<a href="' . Yii::app()->baseUrl . '/order/receipt/' . urlencode(base64_encode(Yii::app()->user->id . '|' . $orderid)) . '">确认收货并评价</a>',
            '4' => '正在发货',
            '5' => '等待收货',
            '6' => '已确认，已评价',
            '7' => '退款'
        );
        return $this->statusarr[$status];
    }

    function zoneProduct($zoneid) {
        $this->zoneproductarr = array(
            '1' => array(
                'tj' => 'id:303+id:255+id:306+id:257+id:258+id:259+id:308+id:261+id:262',
                'ol' => 'id:263+id:302+id:305+id:307+id:309',
                'summer' => 'id:254+id:304+id:256+id:260'
            ),
            '2' => array(
                'tj' => 'id:336+id:319+id:247+id:339+id:291+id:267+id:285+id:318+id:250',
                'ol' => 'id:220+id:250+id:244+id:203+id:338',
                'summer' => 'id:300+id:286+id:273+id:271'
            ),
            '3' => array(
                'tj' => 'id:361+id:362+id:367+id:369+id:371+id:374+id:375+id:378+id:379',
                'ol' => 'id:364+id:366+id:363+id:373+id:377',
                'summer' => 'id:368+id:370+id:372+id:376'
            ),
            '4' => array(
                'tj' => 'id:421+id:424+id:428+id:431+id:434+id:436+id:438+id:439+id:440',
                'ol' => 'id:422+id:426+id:429+id:432+id:435',
                'summer' => 'id:423+id:427+id:430+id:433'
            )
        );
        return $this->zoneproductarr[$zoneid];
    }

    function showMessage($content, $href, $locationtime, $alert) {
//        $href = !$href ? 'javascript:history.go(-1);' : $href;
        $locationtime = !$locationtime ? 3 : $locationtime;
        $content = !$content ? '提示信息' : $content;
        $alert = !$alert ? 'info' : $alert;
        $this->html.= '<div class="nfl">';
        $this->html.= '<div class="f_c altw">';
        $this->html.= '<div id="messagetext" class="alert_' . $alert . '">';
        $this->html.= '<p>' . $content . '</p>';
        if ($href) {
            $this->html.= '<p class="alert_btnleft"><a href="' . Yii::app()->baseUrl . '/' . $href . '">页面' . $locationtime . '秒后自动跳转，如果没跳转请点击此链接</a></p>';
        } else {
            $this->html.= '<p class="alert_btnleft"><a href="javascript:history.go(-1);">返回</a></p>';
        }
        $this->html.= '</div>';
        $this->html.= '</div>';
        $this->html.= '</div>';
        if ($href) {
            $this->html .= '<script type="text/javascript" reload="1">setTimeout("window.location.href =\'' . Yii::app()->baseUrl . '/' . $href . '\';", ' . $locationtime * 1000 . ');</script>';
        }
        return $this->html;
    }

}

?>